﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;

namespace Zero.UControl.Base.Helper.Base
{
    internal class MoveCommand : IDrawingCommand
    {
        private readonly UIElement _element;
        private readonly Vector _delta;
        public MoveCommand(UIElement el, Vector delta)
        {
            _element = el;
            _delta = delta;
        }

        public void Execute()
        {
            double left = Canvas.GetLeft(_element);
            double top = Canvas.GetTop(_element);
            Canvas.SetLeft(_element, left + _delta.X);
            Canvas.SetTop(_element, top + _delta.Y);
        }
        public void UnExecute()
        {
            double left = Canvas.GetLeft(_element);
            double top = Canvas.GetTop(_element);
            Canvas.SetLeft(_element, left - _delta.X);
            Canvas.SetTop(_element, top - _delta.Y);
        }
    }
}
